package com.group.project.hrms.service.impl;

import com.group.project.hrms.entity.AttendanceShiftInfo;
import com.group.project.hrms.mapper.AttendanceShiftInfoMapper;
import com.group.project.hrms.service.IAttendanceShiftInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class AttendanceShiftInfoService implements IAttendanceShiftInfoService {

    @Autowired
    private AttendanceShiftInfoMapper attendanceShiftInfoMapper;

    @Override
    public int insertAttendanceShiftInfo(AttendanceShiftInfo attendanceShiftInfo) {
        return attendanceShiftInfoMapper.insert(attendanceShiftInfo);
    }

    @Override
    public int deleteAttendanceShiftInfo(AttendanceShiftInfo attendanceShiftInfo) {
        return attendanceShiftInfoMapper.deleteByPrimaryKey(attendanceShiftInfo);
    }

    @Override
    public int updateAttendanceShiftInfo(AttendanceShiftInfo attendanceShiftInfo) {
        return attendanceShiftInfoMapper.updateByPrimaryKey(attendanceShiftInfo);
    }

    @Override
    public AttendanceShiftInfo selectOneAttendanceShiftInfo(AttendanceShiftInfo attendanceShiftInfo) {
        return attendanceShiftInfoMapper.selectByPrimaryKey(attendanceShiftInfo);
    }

    @Override
    public AttendanceShiftInfo selectOneAttendanceShiftInfoByShiftID(String sid) {
        Example example = new Example(AttendanceShiftInfo.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("shiftId" , sid);
        return attendanceShiftInfoMapper.selectOneByExample(example);
    }

    @Override
    public List<AttendanceShiftInfo> selectAllAttendanceShiftInfo() {
        return attendanceShiftInfoMapper.selectAll();
    }
}
